
$(function(){

	/*
	if(typeof(sort_name) != "undefined"){
		cur_sort = sort_name[sort_js];
		$("#show_sort").html(cur_sort + '<em></em>');
	}
	*/
	//分类显示
	
	$("#show_categories").click(function(){		
		showArea("navbox");
		$(this).parents("li").addClass("cur");

		return false;
	});
	$("#show_district").click(function(){		
		showArea("navbox_district");
		$(this).parents("li").addClass("cur");
		return false;
	});
	$("#show_sort").click(function(){		
		showArea("navbox_sort");
		$(this).parents("li").addClass("cur");
		return false;
	});
	$("#fullbg").click(function(){
		hideArea("navbox");
		hideArea("navbox_district");
		hideArea("navbox_sort");
		return false;
	});
	$("#fullbg_f").click(function(){
		show_float();
		return false;
	});
	
	$(".cf li a").each(function(){
		if($(this).attr("class") == "cur"){
			$("#cate_3_a").addClass("down");
		}
	})
	
	
	

})

function show_float() {

	$(".circle").toggle();
	if ($(".plusbtn i").hasClass("iconplus")) {
		$(".plusbtn i").removeClass("iconplus");
	} else {
		$(".plusbtn i").addClass("iconplus")
	}
	$('#fullbg_f').toggle();
}
function hide_float() {

	$(".circle").hide();
	if ($(".plusbtn i").hasClass("iconplus")) {
		$(".plusbtn i").removeClass("iconplus");
	}
	$('#fullbg_f').hide();
}
function show_cate2(cate_id,event){
	
	$("#navbox dd a").removeClass("down");
	


	//$('#cate_'+cate_id).toggle();
	$(".category-box").each(function(){
		if($(this).attr("id") == "cate_"+cate_id){
			var cla = $('#'+$(this).attr("id")+"_a").attr("class");
			
			if(cla.indexOf("click")<0)
				$('#'+$(this).attr("id")+"_a").attr("class",cla+" click");
			else
				$('#'+$(this).attr("id")+"_a").attr("class",cla.substr(0,cla.indexOf("click")));
			
			$(this).toggle();
		}else{
			var cla = $('#'+$(this).attr("id")+"_a").attr("class");

			if(cla.indexOf("click") >= 0)
				$('#'+$(this).attr("id")+"_a").attr("class",cla.substr(0,cla.indexOf("click")));
			
			$(this).hide();
		}
		
	})
	$("#cate_"+cate_id+"_a").addClass("down");
	resetHeight();
	
}


function showArea(areaName){
	
	/*setTimeout(function() {
		$('#'+areaName).css( {
			"-webkit-transition" : "-webkit-transform 0.4s",
			"transition" : "-webkit-transform 0.4s",
			"-webkit-transform-origin" : "0px 0px",
			"-webkit-backface-visibility" : "hidden",
			"-webkit-transform-style" : " preserve-3d",
			"-webkit-transform" : "translate(0, 0)"
		});
	}
	,1);*/
	$('#'+areaName).show();
	$('#fullbg').show();
	
	resetHeight();
}
function hideArea(areaName){
	$('#'+areaName).removeAttr("style");

	/*$('#'+areaName).css( {
		"-webkit-transition" : "-webkit-transform 0.4s",
		"transition" : "-webkit-transform 0.4s",
		"-webkit-transform-origin" : "0px 0px",
		"-webkit-backface-visibility" : "hidden",
		"-webkit-transform-style" : " preserve-3d",
		"-webkit-transform" : "translate(280, 0)"
	});*/
	$('#'+areaName).hide();

	$('#fullbg').hide();
	$('#'+areaName).removeAttr("style");
	$(".mall-cate li").removeClass("cur");
}

function resetHeight(){
	//页面高度随菜单高度变化
	var cate_height = $("#navbox_inner").height();
	
	var district_height = $("#navbox_district_inner").height();
	
	var min_height = cate_height;
	if(cate_height < district_height)
		min_height = district_height;
	
	var v3_height = parseInt($(".v3").css("height"));

	if(min_height > v3_height){
		$(".v3").css("height",min_height+'px');
	}
}



function hideAllArea(){
	hideArea("navbox");
	hideArea("navbox_district");
	hideArea("navbox_sort");
	$("#distance_a").text('离我最近');
}


function getCookie(name){
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
     if(arr != null) return unescape(arr[2]); return null;

}